#pragma once
#include <string>

using namespace std;

struct Card
{

	enum CardValue
	{
		ValueEror = 0,		
		K2 = 1,
		K3 = 2,
		K4 = 3,
		K5 = 4,
		K6 = 5,
		K7 = 6,
		K8 = 7,
		K9 = 8,
		T = 9,
		J = 10,
		Q = 11,
		K = 12,
		A = 13,
	};

	enum CardLear
	{
		LearEror = 0,
		Heart = 1,
		Diamonds = 2,
		Club = 3,
		Peak = 4,
	};


	Card()
	{
		value = ValueEror;
		lear = LearEror;
	}
	
	Card(CardValue value, CardLear lear)
	:value(value)
	,lear(lear)
	{		  
	}

	virtual ~Card(){}

	bool operator==(Card card)
	{
		if (this->value == card.GetValue() && this->lear == card.GetLear())
			return true;
		else
			return false;
	}

	string GetCardStr()
	{
		string card = "__";
		card[0] = StrFromValue(value);
		card[1] = StrFromLear(lear);
		return card;
	}

	void SetCard(string card)
	{
		value = ValueFromStr(card[0]);
		lear = LearFromStr(card[1]);
	}

	void SetCard(Card card)
	{
		value = card.value;
		lear = card.lear;
	}

	void SetLear(CardLear l)
	{
		lear = l;
	}

	void SetValue(CardValue v)
	{
		value = v;
	}

	CardLear LearFromStr(char c)
	{
		if (c == 3)
			return Heart;
		else if (c == 4)
			return Diamonds;
		else if (c == 5)
			return Club;
		else if (c == 6)
			return Peak;
		else
			//////////////////////////////////////////////////////////////////////////
			//Print Erorr;
			return LearEror;
	}

	CardLear GetLear()
	{
		return lear;
	}

	CardValue ValueFromStr(char c)
	{
		if (c > 49 && c < 58)
		{
			return CardValue(A + unsigned(c - 49));
		} else if (c == 'T')
			return T;
		else if (c == 'J')
			return J;
		else if (c == 'Q')
			return Q;
		else if (c == 'K')
			return K;
		else if (c == 'A')
			return A;
		else
			//////////////////////////////////////////////////////////////////////////
			//Print Erorr;
			return ValueEror;
	}

	CardValue GetValue()
	{
		return value;
	}

	char StrFromValue(CardValue v)
	{
		if (v >= K2 && v < T)
			return '1' + char(v);
		else if (v == T)
			return 'T';
		else if (v == J)
			return 'J';
		else if (v == Q)
			return 'Q';
		else if (v == K)
			return 'K';
		else if (v == A)
			return 'A';
		else
			//////////////////////////////////////////////////////////////////////////
			//Print Erorr;
			return 0;
	}

	char StrFromLear(CardLear l)
	{
		return 2 + l;
	}

	bool IsRed()
	{
		if (lear == Heart || lear == Diamonds)
			return true;
		else
			return false;
	}

	bool IsBlack()
	{
		if (lear == Club || lear == Peak)
			return true;
		else
			return false;
	}

	char GetLearStr()
	{
		char c = StrFromLear(lear);
		return c;
	}
	char GetValueStr()		
	{
		char c = StrFromValue(value);
		return c;
	}

private:
	CardValue value;
	CardLear lear;
};